package com.example.light.web.system.dao;

import com.example.light.web.system.entity.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DepartmentMapper {
    int deleteByPrimaryKey(Integer deptId);

    Department selectByPrimaryKey(Integer deptId);



    @Insert("insert into department(dept_id,dept_name,dept_description,dept_people," +
            "dept_contact,dept_create_time) " +
            "values(#{deptId},#{deptName},#{deptMemo},#{deptPeople},#{deptTel},#{createTime})")
    int add(Department record);

    @Delete("delete from department where dept_id in(#{ids})")
    void deletM(Integer [] ids);

    @Results(id="DeptResults",value = {
            @Result(property = "deptId",column = "dept_id"),
            @Result(property = "deptName",column = "dept_name"),
            @Result(property = "deptMemo",column = "dept_description"),
            @Result(property = "deptPeople",column = "dept_people"),
            @Result(property = "deptTel",column = "dept_contact"),
            @Result(property = "createTime",column = "dept_create_time")
    })
    @Select("select * from department")
    public List<Department> Querall();

    @Update("update department set dept_name=#{deptName},dept_description=#{deptMemo},dept_people=#{deptPeople},dept_contact=#{deptTel}," +
            "dept_create_time=#{createTime} where dept_id=#{deptId}")
    public int update(Department dept);

    @ResultMap("DeptResults")
    @Select("select * from department " +
            "where dept_name = #{deptName}")
    public Department selectDeptId(String deptName);
}